var app = getApp(),
  $ = require("../../utils/httpHelper.js")
Page({
  data: {
    erwemapop: false,
    erweima_img:'',
    isdaili:true,
    isjxs:true,
    isme:true
  },
  onShareAppMessage: function (res) {
    app.shareApp(res)
  },
  onLoad: function (e) {
    var that = this;
    this.setData({ userInfo: app.globalData.userInfo })
    let memberType = wx.getStorageSync('member_type')
    if (memberType == 4 || memberType == 6 || memberType == 31) {
      this.setData({
        isdaili: true,
        isjxs: false
      })
    } else if (memberType == 8 || memberType == 16 || memberType == 24
      || memberType == 30){
      this.setData({
        isdaili: false,
        isjxs: false
      })
    } else if (memberType == 2){
      this.setData({
        isdaili: false,
        isjxs:true
      })
    }else{
      this.setData({
        isdaili: false,
        isjxs: false,
        isme:false
      })
    }
  },
  onShow:function(e){
    
  },
  
  toyqing(e) {
    console.log(e)
    let types = e.currentTarget.dataset.type
    let par = {
      rd_session: app.globalData.userInfo.rd_session,
      types:types
    }
    $.httpPost("create_qrcode", par, (data, err) => {
      this.setData({
        erweima_img: data.data.qrcode,
        erwemapop: true
      })
    })
  },
  closeerweima() {
    this.setData({
      erwemapop: false
    })
  },

  save(){
    let that = this
    wx.downloadFile({
      url: this.data.erweima_img,
      success: function (res) {
        console.log(res)
        wx.saveImageToPhotosAlbum({
          filePath: res.tempFilePath,
          success: function (res) {
            wx.showToast({
              title: '保存成功',
            })
            that.setData({
              erwemapop: false
            })
          },
          fail: function (res) {
            console.log(res)
            console.log('fail')
          }
        })
      },
      fail: function () {
        console.log('fail')
      }
    })  
  }
  
});